package com.ruoyi.performance.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.performance.domain.PerfGroup;
import com.ruoyi.performance.domain.PerfTemplate;
import com.ruoyi.performance.mapper.PerfGroupMapper;
import com.ruoyi.performance.service.PerfGroupService;
import com.ruoyi.performance.service.PerfTemplateService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class PerfGroupServiceImpl implements PerfGroupService {
    @Autowired
    PerfGroupMapper perfGroupMapper;

    @Override
    public List<PerfGroup> selectPerfGroupById(Long id){
        return perfGroupMapper.selectPerfGroupById(id);
    }

    @Override
    public List<PerfGroup> selectPerfGroupByCompanycode(String Companycode) {
        return perfGroupMapper.selectPerfGroupByCompanycode(Companycode);
    }

    @Override
    public List<PerfGroup> selectPerfGroupList(PerfGroup perfGroup){
        return perfGroupMapper.selectPerfGroupList(perfGroup);
    }

    @Override
    public List<PerfGroup> selectPerfGroupByGroupcode(String groupcode){
        return perfGroupMapper.selectPerfGroupByGroupcode(groupcode);
    }

    @Override
    public List<PerfGroup> selectPerfGroupByGroupname(String groupname){
        return perfGroupMapper.selectPerfGroupByGroupname(groupname);
    }

    @Override
    public List<PerfGroup> selectPerfGroupByCompanycodeAndGroupcodeAndGroupname(@Param("companycode") String companycode,@Param("groupcode") String groupcode,@Param("groupname") String groupname){
        return perfGroupMapper.selectPerfGroupByCompanycodeAndGroupcodeAndGroupname(companycode, groupcode, groupname);
    }

    @Override
    public List<PerfGroup> selectPerfGroupByCompanycodeAndGroupcode(@Param("companycode") String companycode,@Param("groupcode") String groupcode){
        return perfGroupMapper.selectPerfGroupByCompanycodeAndGroupcode(companycode, groupcode);
    }

    @Override
    public int insertPerfGroup(PerfGroup perfGroup){
        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
        perfGroup.setCreatedate(date);
        perfGroup.setCreatetime(time);
        return perfGroupMapper.insertPerfGroup(perfGroup);
    }

    @Override
    public int updatePerfGroup(PerfGroup perfGroup){
        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
        perfGroup.setCreatedate(date);
        perfGroup.setCreatetime(time);
        return perfGroupMapper.updatePerfGroup(perfGroup);
    }

    @Override
    public int deletePerfGroupById(String id){
        return perfGroupMapper.deletePerfGroupById(Convert.toStrArray(id));
    }
}
